package com.authine.cloudpivot.ext.enums.goods;

import java.util.Arrays;

/**
 * @Author: fj
 * @Date: 2021/6/7 20:27
 * @Version 1.0
 */
public enum GoodsType {

    Mall("固买商城"),
    Single("单次采购"),
    Loop("多次采购"),
    Virtual("虚拟商品"),
    EnterpriseMall("企业商城");

    public String desc;

    GoodsType(String desc) {

        this.desc = desc;
    }

    public static GoodsType get(String desc) {

        return Arrays.stream(GoodsType.values()).filter(v -> v.desc.equals(desc)).findFirst().orElse(null);
    }

    /**
     * @param ordinal
     * @return
     */
    public static GoodsType get(Integer ordinal) {
        if (ordinal == null) {
            return null;
        } else {
            return Arrays.stream(GoodsType.values()).filter(v -> v.ordinal() == ordinal).findFirst().orElse(null);
        }

    }

    @Override
    public String toString() {
        return desc;
    }
}
